﻿/**  版本信息模板在安装目录下，可自行修改。
* V_Orders.cs
*
* 功 能： N/A
* 类 名： V_Orders
*
* Ver    变更日期             负责人  变更内容
* ───────────────────────────────────
* V0.01  2014/3/7 13:58:29   N/A    初版
*
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
*┌──────────────────────────────────┐
*│　此技术信息为本公司机密信息，未经本公司书面同意禁止向第三方披露．　│
*│　版权所有：动软卓越（北京）科技有限公司　　　　　　　　　　　　　　│
*└──────────────────────────────────┘
*/
using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using Maticsoft.DBUtility;//Please add references
namespace BBPA.DAL
{
	/// <summary>
	/// 数据访问类:V_Orders
	/// </summary>
	public partial class V_Orders
	{
		public V_Orders()
		{}
		#region  BasicMethod



		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(BBPA.Model.V_Orders model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into V_Orders(");
			strSql.Append("id,Number,StoreID,State,Dateandtime,ExpectPriceSum,ActualPriceSum,ExpressPrice,StoreName,StoreNumber,DateandtimeSend,ActualBuyPriceSum,ExpectBuyPriceSum,IsBuyMoneyOK,ExpectPay,ActualPay,ExpressName,ExpressNumber,StoreProvince,StoreCity,StoreArea,StoreMobile,StoreTel,StoreContacts,StoreAddress,BuyDay,ExpectBuyDate,StoreAccount,StoreMasterAccount,StoreViceAccount,StoreFrozenAccount,ExpressID,ExpressTel,ExpressMobile,ExpressCode,ExpressDescription,BuyerID,SenderID,BuyerNumber,BuyerRealname,BuyerMobile,StoreUserID,BuyerUserID,FirstExpectBuyDate,ActualPay_Delivery,ExpectPay_Delivery,HasPay_Delivery,HasPay,IsBuyMoneyOK_Delivery)");
			strSql.Append(" values (");
			strSql.Append("@id,@Number,@StoreID,@State,@Dateandtime,@ExpectPriceSum,@ActualPriceSum,@ExpressPrice,@StoreName,@StoreNumber,@DateandtimeSend,@ActualBuyPriceSum,@ExpectBuyPriceSum,@IsBuyMoneyOK,@ExpectPay,@ActualPay,@ExpressName,@ExpressNumber,@StoreProvince,@StoreCity,@StoreArea,@StoreMobile,@StoreTel,@StoreContacts,@StoreAddress,@BuyDay,@ExpectBuyDate,@StoreAccount,@StoreMasterAccount,@StoreViceAccount,@StoreFrozenAccount,@ExpressID,@ExpressTel,@ExpressMobile,@ExpressCode,@ExpressDescription,@BuyerID,@SenderID,@BuyerNumber,@BuyerRealname,@BuyerMobile,@StoreUserID,@BuyerUserID,@FirstExpectBuyDate,@ActualPay_Delivery,@ExpectPay_Delivery,@HasPay_Delivery,@HasPay,@IsBuyMoneyOK_Delivery)");
			SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.Int,4),
					new SqlParameter("@Number", SqlDbType.VarChar,50),
					new SqlParameter("@StoreID", SqlDbType.Int,4),
					new SqlParameter("@State", SqlDbType.TinyInt,1),
					new SqlParameter("@Dateandtime", SqlDbType.DateTime),
					new SqlParameter("@ExpectPriceSum", SqlDbType.Money,8),
					new SqlParameter("@ActualPriceSum", SqlDbType.Money,8),
					new SqlParameter("@ExpressPrice", SqlDbType.Money,8),
					new SqlParameter("@StoreName", SqlDbType.NVarChar,50),
					new SqlParameter("@StoreNumber", SqlDbType.NVarChar,50),
					new SqlParameter("@DateandtimeSend", SqlDbType.DateTime),
					new SqlParameter("@ActualBuyPriceSum", SqlDbType.Money,8),
					new SqlParameter("@ExpectBuyPriceSum", SqlDbType.Money,8),
					new SqlParameter("@IsBuyMoneyOK", SqlDbType.Bit,1),
					new SqlParameter("@ExpectPay", SqlDbType.Money,8),
					new SqlParameter("@ActualPay", SqlDbType.Money,8),
					new SqlParameter("@ExpressName", SqlDbType.NVarChar,50),
					new SqlParameter("@ExpressNumber", SqlDbType.VarChar,50),
					new SqlParameter("@StoreProvince", SqlDbType.NVarChar,50),
					new SqlParameter("@StoreCity", SqlDbType.NVarChar,50),
					new SqlParameter("@StoreArea", SqlDbType.NVarChar,50),
					new SqlParameter("@StoreMobile", SqlDbType.VarChar,50),
					new SqlParameter("@StoreTel", SqlDbType.NVarChar,50),
					new SqlParameter("@StoreContacts", SqlDbType.NVarChar,50),
					new SqlParameter("@StoreAddress", SqlDbType.NVarChar,200),
					new SqlParameter("@BuyDay", SqlDbType.TinyInt,1),
					new SqlParameter("@ExpectBuyDate", SqlDbType.DateTime),
					new SqlParameter("@StoreAccount", SqlDbType.Money,8),
					new SqlParameter("@StoreMasterAccount", SqlDbType.Money,8),
					new SqlParameter("@StoreViceAccount", SqlDbType.Money,8),
					new SqlParameter("@StoreFrozenAccount", SqlDbType.Money,8),
					new SqlParameter("@ExpressID", SqlDbType.Int,4),
					new SqlParameter("@ExpressTel", SqlDbType.NChar,10),
					new SqlParameter("@ExpressMobile", SqlDbType.NChar,10),
					new SqlParameter("@ExpressCode", SqlDbType.VarChar,50),
					new SqlParameter("@ExpressDescription", SqlDbType.NChar,10),
					new SqlParameter("@BuyerID", SqlDbType.Int,4),
					new SqlParameter("@SenderID", SqlDbType.Int,4),
					new SqlParameter("@BuyerNumber", SqlDbType.VarChar,50),
					new SqlParameter("@BuyerRealname", SqlDbType.NVarChar,50),
					new SqlParameter("@BuyerMobile", SqlDbType.VarChar,11),
					new SqlParameter("@StoreUserID", SqlDbType.Int,4),
					new SqlParameter("@BuyerUserID", SqlDbType.Int,4),
					new SqlParameter("@FirstExpectBuyDate", SqlDbType.Date,3),
					new SqlParameter("@ActualPay_Delivery", SqlDbType.Money,8),
					new SqlParameter("@ExpectPay_Delivery", SqlDbType.Money,8),
					new SqlParameter("@HasPay_Delivery", SqlDbType.Bit,1),
					new SqlParameter("@HasPay", SqlDbType.Bit,1),
					new SqlParameter("@IsBuyMoneyOK_Delivery", SqlDbType.Bit,1)};
			parameters[0].Value = model.id;
			parameters[1].Value = model.Number;
			parameters[2].Value = model.StoreID;
			parameters[3].Value = model.State;
			parameters[4].Value = model.Dateandtime;
			parameters[5].Value = model.ExpectPriceSum;
			parameters[6].Value = model.ActualPriceSum;
			parameters[7].Value = model.ExpressPrice;
			parameters[8].Value = model.StoreName;
			parameters[9].Value = model.StoreNumber;
			parameters[10].Value = model.DateandtimeSend;
			parameters[11].Value = model.ActualBuyPriceSum;
			parameters[12].Value = model.ExpectBuyPriceSum;
			parameters[13].Value = model.IsBuyMoneyOK;
			parameters[14].Value = model.ExpectPay;
			parameters[15].Value = model.ActualPay;
			parameters[16].Value = model.ExpressName;
			parameters[17].Value = model.ExpressNumber;
			parameters[18].Value = model.StoreProvince;
			parameters[19].Value = model.StoreCity;
			parameters[20].Value = model.StoreArea;
			parameters[21].Value = model.StoreMobile;
			parameters[22].Value = model.StoreTel;
			parameters[23].Value = model.StoreContacts;
			parameters[24].Value = model.StoreAddress;
			parameters[25].Value = model.BuyDay;
			parameters[26].Value = model.ExpectBuyDate;
			parameters[27].Value = model.StoreAccount;
			parameters[28].Value = model.StoreMasterAccount;
			parameters[29].Value = model.StoreViceAccount;
			parameters[30].Value = model.StoreFrozenAccount;
			parameters[31].Value = model.ExpressID;
			parameters[32].Value = model.ExpressTel;
			parameters[33].Value = model.ExpressMobile;
			parameters[34].Value = model.ExpressCode;
			parameters[35].Value = model.ExpressDescription;
			parameters[36].Value = model.BuyerID;
			parameters[37].Value = model.SenderID;
			parameters[38].Value = model.BuyerNumber;
			parameters[39].Value = model.BuyerRealname;
			parameters[40].Value = model.BuyerMobile;
			parameters[41].Value = model.StoreUserID;
			parameters[42].Value = model.BuyerUserID;
			parameters[43].Value = model.FirstExpectBuyDate;
			parameters[44].Value = model.ActualPay_Delivery;
			parameters[45].Value = model.ExpectPay_Delivery;
			parameters[46].Value = model.HasPay_Delivery;
			parameters[47].Value = model.HasPay;
			parameters[48].Value = model.IsBuyMoneyOK_Delivery;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(BBPA.Model.V_Orders model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update V_Orders set ");
			strSql.Append("id=@id,");
			strSql.Append("Number=@Number,");
			strSql.Append("StoreID=@StoreID,");
			strSql.Append("State=@State,");
			strSql.Append("Dateandtime=@Dateandtime,");
			strSql.Append("ExpectPriceSum=@ExpectPriceSum,");
			strSql.Append("ActualPriceSum=@ActualPriceSum,");
			strSql.Append("ExpressPrice=@ExpressPrice,");
			strSql.Append("StoreName=@StoreName,");
			strSql.Append("StoreNumber=@StoreNumber,");
			strSql.Append("DateandtimeSend=@DateandtimeSend,");
			strSql.Append("ActualBuyPriceSum=@ActualBuyPriceSum,");
			strSql.Append("ExpectBuyPriceSum=@ExpectBuyPriceSum,");
			strSql.Append("IsBuyMoneyOK=@IsBuyMoneyOK,");
			strSql.Append("ExpectPay=@ExpectPay,");
			strSql.Append("ActualPay=@ActualPay,");
			strSql.Append("ExpressName=@ExpressName,");
			strSql.Append("ExpressNumber=@ExpressNumber,");
			strSql.Append("StoreProvince=@StoreProvince,");
			strSql.Append("StoreCity=@StoreCity,");
			strSql.Append("StoreArea=@StoreArea,");
			strSql.Append("StoreMobile=@StoreMobile,");
			strSql.Append("StoreTel=@StoreTel,");
			strSql.Append("StoreContacts=@StoreContacts,");
			strSql.Append("StoreAddress=@StoreAddress,");
			strSql.Append("BuyDay=@BuyDay,");
			strSql.Append("ExpectBuyDate=@ExpectBuyDate,");
			strSql.Append("StoreAccount=@StoreAccount,");
			strSql.Append("StoreMasterAccount=@StoreMasterAccount,");
			strSql.Append("StoreViceAccount=@StoreViceAccount,");
			strSql.Append("StoreFrozenAccount=@StoreFrozenAccount,");
			strSql.Append("ExpressID=@ExpressID,");
			strSql.Append("ExpressTel=@ExpressTel,");
			strSql.Append("ExpressMobile=@ExpressMobile,");
			strSql.Append("ExpressCode=@ExpressCode,");
			strSql.Append("ExpressDescription=@ExpressDescription,");
			strSql.Append("BuyerID=@BuyerID,");
			strSql.Append("SenderID=@SenderID,");
			strSql.Append("BuyerNumber=@BuyerNumber,");
			strSql.Append("BuyerRealname=@BuyerRealname,");
			strSql.Append("BuyerMobile=@BuyerMobile,");
			strSql.Append("StoreUserID=@StoreUserID,");
			strSql.Append("BuyerUserID=@BuyerUserID,");
			strSql.Append("FirstExpectBuyDate=@FirstExpectBuyDate,");
			strSql.Append("ActualPay_Delivery=@ActualPay_Delivery,");
			strSql.Append("ExpectPay_Delivery=@ExpectPay_Delivery,");
			strSql.Append("HasPay_Delivery=@HasPay_Delivery,");
			strSql.Append("HasPay=@HasPay,");
			strSql.Append("IsBuyMoneyOK_Delivery=@IsBuyMoneyOK_Delivery");
			strSql.Append(" where ");
			SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.Int,4),
					new SqlParameter("@Number", SqlDbType.VarChar,50),
					new SqlParameter("@StoreID", SqlDbType.Int,4),
					new SqlParameter("@State", SqlDbType.TinyInt,1),
					new SqlParameter("@Dateandtime", SqlDbType.DateTime),
					new SqlParameter("@ExpectPriceSum", SqlDbType.Money,8),
					new SqlParameter("@ActualPriceSum", SqlDbType.Money,8),
					new SqlParameter("@ExpressPrice", SqlDbType.Money,8),
					new SqlParameter("@StoreName", SqlDbType.NVarChar,50),
					new SqlParameter("@StoreNumber", SqlDbType.NVarChar,50),
					new SqlParameter("@DateandtimeSend", SqlDbType.DateTime),
					new SqlParameter("@ActualBuyPriceSum", SqlDbType.Money,8),
					new SqlParameter("@ExpectBuyPriceSum", SqlDbType.Money,8),
					new SqlParameter("@IsBuyMoneyOK", SqlDbType.Bit,1),
					new SqlParameter("@ExpectPay", SqlDbType.Money,8),
					new SqlParameter("@ActualPay", SqlDbType.Money,8),
					new SqlParameter("@ExpressName", SqlDbType.NVarChar,50),
					new SqlParameter("@ExpressNumber", SqlDbType.VarChar,50),
					new SqlParameter("@StoreProvince", SqlDbType.NVarChar,50),
					new SqlParameter("@StoreCity", SqlDbType.NVarChar,50),
					new SqlParameter("@StoreArea", SqlDbType.NVarChar,50),
					new SqlParameter("@StoreMobile", SqlDbType.VarChar,50),
					new SqlParameter("@StoreTel", SqlDbType.NVarChar,50),
					new SqlParameter("@StoreContacts", SqlDbType.NVarChar,50),
					new SqlParameter("@StoreAddress", SqlDbType.NVarChar,200),
					new SqlParameter("@BuyDay", SqlDbType.TinyInt,1),
					new SqlParameter("@ExpectBuyDate", SqlDbType.DateTime),
					new SqlParameter("@StoreAccount", SqlDbType.Money,8),
					new SqlParameter("@StoreMasterAccount", SqlDbType.Money,8),
					new SqlParameter("@StoreViceAccount", SqlDbType.Money,8),
					new SqlParameter("@StoreFrozenAccount", SqlDbType.Money,8),
					new SqlParameter("@ExpressID", SqlDbType.Int,4),
					new SqlParameter("@ExpressTel", SqlDbType.NChar,10),
					new SqlParameter("@ExpressMobile", SqlDbType.NChar,10),
					new SqlParameter("@ExpressCode", SqlDbType.VarChar,50),
					new SqlParameter("@ExpressDescription", SqlDbType.NChar,10),
					new SqlParameter("@BuyerID", SqlDbType.Int,4),
					new SqlParameter("@SenderID", SqlDbType.Int,4),
					new SqlParameter("@BuyerNumber", SqlDbType.VarChar,50),
					new SqlParameter("@BuyerRealname", SqlDbType.NVarChar,50),
					new SqlParameter("@BuyerMobile", SqlDbType.VarChar,11),
					new SqlParameter("@StoreUserID", SqlDbType.Int,4),
					new SqlParameter("@BuyerUserID", SqlDbType.Int,4),
					new SqlParameter("@FirstExpectBuyDate", SqlDbType.Date,3),
					new SqlParameter("@ActualPay_Delivery", SqlDbType.Money,8),
					new SqlParameter("@ExpectPay_Delivery", SqlDbType.Money,8),
					new SqlParameter("@HasPay_Delivery", SqlDbType.Bit,1),
					new SqlParameter("@HasPay", SqlDbType.Bit,1),
					new SqlParameter("@IsBuyMoneyOK_Delivery", SqlDbType.Bit,1)};
			parameters[0].Value = model.id;
			parameters[1].Value = model.Number;
			parameters[2].Value = model.StoreID;
			parameters[3].Value = model.State;
			parameters[4].Value = model.Dateandtime;
			parameters[5].Value = model.ExpectPriceSum;
			parameters[6].Value = model.ActualPriceSum;
			parameters[7].Value = model.ExpressPrice;
			parameters[8].Value = model.StoreName;
			parameters[9].Value = model.StoreNumber;
			parameters[10].Value = model.DateandtimeSend;
			parameters[11].Value = model.ActualBuyPriceSum;
			parameters[12].Value = model.ExpectBuyPriceSum;
			parameters[13].Value = model.IsBuyMoneyOK;
			parameters[14].Value = model.ExpectPay;
			parameters[15].Value = model.ActualPay;
			parameters[16].Value = model.ExpressName;
			parameters[17].Value = model.ExpressNumber;
			parameters[18].Value = model.StoreProvince;
			parameters[19].Value = model.StoreCity;
			parameters[20].Value = model.StoreArea;
			parameters[21].Value = model.StoreMobile;
			parameters[22].Value = model.StoreTel;
			parameters[23].Value = model.StoreContacts;
			parameters[24].Value = model.StoreAddress;
			parameters[25].Value = model.BuyDay;
			parameters[26].Value = model.ExpectBuyDate;
			parameters[27].Value = model.StoreAccount;
			parameters[28].Value = model.StoreMasterAccount;
			parameters[29].Value = model.StoreViceAccount;
			parameters[30].Value = model.StoreFrozenAccount;
			parameters[31].Value = model.ExpressID;
			parameters[32].Value = model.ExpressTel;
			parameters[33].Value = model.ExpressMobile;
			parameters[34].Value = model.ExpressCode;
			parameters[35].Value = model.ExpressDescription;
			parameters[36].Value = model.BuyerID;
			parameters[37].Value = model.SenderID;
			parameters[38].Value = model.BuyerNumber;
			parameters[39].Value = model.BuyerRealname;
			parameters[40].Value = model.BuyerMobile;
			parameters[41].Value = model.StoreUserID;
			parameters[42].Value = model.BuyerUserID;
			parameters[43].Value = model.FirstExpectBuyDate;
			parameters[44].Value = model.ActualPay_Delivery;
			parameters[45].Value = model.ExpectPay_Delivery;
			parameters[46].Value = model.HasPay_Delivery;
			parameters[47].Value = model.HasPay;
			parameters[48].Value = model.IsBuyMoneyOK_Delivery;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from V_Orders ");
			strSql.Append(" where ");
			SqlParameter[] parameters = {
			};

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public BBPA.Model.V_Orders GetModel()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 id,Number,StoreID,State,Dateandtime,ExpectPriceSum,ActualPriceSum,ExpressPrice,StoreName,StoreNumber,DateandtimeSend,ActualBuyPriceSum,ExpectBuyPriceSum,IsBuyMoneyOK,ExpectPay,ActualPay,ExpressName,ExpressNumber,StoreProvince,StoreCity,StoreArea,StoreMobile,StoreTel,StoreContacts,StoreAddress,BuyDay,ExpectBuyDate,StoreAccount,StoreMasterAccount,StoreViceAccount,StoreFrozenAccount,ExpressID,ExpressTel,ExpressMobile,ExpressCode,ExpressDescription,BuyerID,SenderID,BuyerNumber,BuyerRealname,BuyerMobile,StoreUserID,BuyerUserID,FirstExpectBuyDate,ActualPay_Delivery,ExpectPay_Delivery,HasPay_Delivery,HasPay,IsBuyMoneyOK_Delivery from V_Orders ");
			strSql.Append(" where ");
			SqlParameter[] parameters = {
			};

			BBPA.Model.V_Orders model=new BBPA.Model.V_Orders();
			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				return DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
				return null;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public BBPA.Model.V_Orders DataRowToModel(DataRow row)
		{
			BBPA.Model.V_Orders model=new BBPA.Model.V_Orders();
			if (row != null)
			{
				if(row["id"]!=null && row["id"].ToString()!="")
				{
					model.id=int.Parse(row["id"].ToString());
				}
				if(row["Number"]!=null)
				{
					model.Number=row["Number"].ToString();
				}
				if(row["StoreID"]!=null && row["StoreID"].ToString()!="")
				{
					model.StoreID=int.Parse(row["StoreID"].ToString());
				}
				if(row["State"]!=null && row["State"].ToString()!="")
				{
					model.State=int.Parse(row["State"].ToString());
				}
				if(row["Dateandtime"]!=null && row["Dateandtime"].ToString()!="")
				{
					model.Dateandtime=DateTime.Parse(row["Dateandtime"].ToString());
				}
				if(row["ExpectPriceSum"]!=null && row["ExpectPriceSum"].ToString()!="")
				{
					model.ExpectPriceSum=decimal.Parse(row["ExpectPriceSum"].ToString());
				}
				if(row["ActualPriceSum"]!=null && row["ActualPriceSum"].ToString()!="")
				{
					model.ActualPriceSum=decimal.Parse(row["ActualPriceSum"].ToString());
				}
				if(row["ExpressPrice"]!=null && row["ExpressPrice"].ToString()!="")
				{
					model.ExpressPrice=decimal.Parse(row["ExpressPrice"].ToString());
				}
				if(row["StoreName"]!=null)
				{
					model.StoreName=row["StoreName"].ToString();
				}
				if(row["StoreNumber"]!=null)
				{
					model.StoreNumber=row["StoreNumber"].ToString();
				}
				if(row["DateandtimeSend"]!=null && row["DateandtimeSend"].ToString()!="")
				{
					model.DateandtimeSend=DateTime.Parse(row["DateandtimeSend"].ToString());
				}
				if(row["ActualBuyPriceSum"]!=null && row["ActualBuyPriceSum"].ToString()!="")
				{
					model.ActualBuyPriceSum=decimal.Parse(row["ActualBuyPriceSum"].ToString());
				}
				if(row["ExpectBuyPriceSum"]!=null && row["ExpectBuyPriceSum"].ToString()!="")
				{
					model.ExpectBuyPriceSum=decimal.Parse(row["ExpectBuyPriceSum"].ToString());
				}
				if(row["IsBuyMoneyOK"]!=null && row["IsBuyMoneyOK"].ToString()!="")
				{
					if((row["IsBuyMoneyOK"].ToString()=="1")||(row["IsBuyMoneyOK"].ToString().ToLower()=="true"))
					{
						model.IsBuyMoneyOK=true;
					}
					else
					{
						model.IsBuyMoneyOK=false;
					}
				}
				if(row["ExpectPay"]!=null && row["ExpectPay"].ToString()!="")
				{
					model.ExpectPay=decimal.Parse(row["ExpectPay"].ToString());
				}
				if(row["ActualPay"]!=null && row["ActualPay"].ToString()!="")
				{
					model.ActualPay=decimal.Parse(row["ActualPay"].ToString());
				}
				if(row["ExpressName"]!=null)
				{
					model.ExpressName=row["ExpressName"].ToString();
				}
				if(row["ExpressNumber"]!=null)
				{
					model.ExpressNumber=row["ExpressNumber"].ToString();
				}
				if(row["StoreProvince"]!=null)
				{
					model.StoreProvince=row["StoreProvince"].ToString();
				}
				if(row["StoreCity"]!=null)
				{
					model.StoreCity=row["StoreCity"].ToString();
				}
				if(row["StoreArea"]!=null)
				{
					model.StoreArea=row["StoreArea"].ToString();
				}
				if(row["StoreMobile"]!=null)
				{
					model.StoreMobile=row["StoreMobile"].ToString();
				}
				if(row["StoreTel"]!=null)
				{
					model.StoreTel=row["StoreTel"].ToString();
				}
				if(row["StoreContacts"]!=null)
				{
					model.StoreContacts=row["StoreContacts"].ToString();
				}
				if(row["StoreAddress"]!=null)
				{
					model.StoreAddress=row["StoreAddress"].ToString();
				}
				if(row["BuyDay"]!=null && row["BuyDay"].ToString()!="")
				{
					model.BuyDay=int.Parse(row["BuyDay"].ToString());
				}
				if(row["ExpectBuyDate"]!=null && row["ExpectBuyDate"].ToString()!="")
				{
					model.ExpectBuyDate=DateTime.Parse(row["ExpectBuyDate"].ToString());
				}
				if(row["StoreAccount"]!=null && row["StoreAccount"].ToString()!="")
				{
					model.StoreAccount=decimal.Parse(row["StoreAccount"].ToString());
				}
				if(row["StoreMasterAccount"]!=null && row["StoreMasterAccount"].ToString()!="")
				{
					model.StoreMasterAccount=decimal.Parse(row["StoreMasterAccount"].ToString());
				}
				if(row["StoreViceAccount"]!=null && row["StoreViceAccount"].ToString()!="")
				{
					model.StoreViceAccount=decimal.Parse(row["StoreViceAccount"].ToString());
				}
				if(row["StoreFrozenAccount"]!=null && row["StoreFrozenAccount"].ToString()!="")
				{
					model.StoreFrozenAccount=decimal.Parse(row["StoreFrozenAccount"].ToString());
				}
				if(row["ExpressID"]!=null && row["ExpressID"].ToString()!="")
				{
					model.ExpressID=int.Parse(row["ExpressID"].ToString());
				}
				if(row["ExpressTel"]!=null)
				{
					model.ExpressTel=row["ExpressTel"].ToString();
				}
				if(row["ExpressMobile"]!=null)
				{
					model.ExpressMobile=row["ExpressMobile"].ToString();
				}
				if(row["ExpressCode"]!=null)
				{
					model.ExpressCode=row["ExpressCode"].ToString();
				}
				if(row["ExpressDescription"]!=null)
				{
					model.ExpressDescription=row["ExpressDescription"].ToString();
				}
				if(row["BuyerID"]!=null && row["BuyerID"].ToString()!="")
				{
					model.BuyerID=int.Parse(row["BuyerID"].ToString());
				}
				if(row["SenderID"]!=null && row["SenderID"].ToString()!="")
				{
					model.SenderID=int.Parse(row["SenderID"].ToString());
				}
				if(row["BuyerNumber"]!=null)
				{
					model.BuyerNumber=row["BuyerNumber"].ToString();
				}
				if(row["BuyerRealname"]!=null)
				{
					model.BuyerRealname=row["BuyerRealname"].ToString();
				}
				if(row["BuyerMobile"]!=null)
				{
					model.BuyerMobile=row["BuyerMobile"].ToString();
				}
				if(row["StoreUserID"]!=null && row["StoreUserID"].ToString()!="")
				{
					model.StoreUserID=int.Parse(row["StoreUserID"].ToString());
				}
				if(row["BuyerUserID"]!=null && row["BuyerUserID"].ToString()!="")
				{
					model.BuyerUserID=int.Parse(row["BuyerUserID"].ToString());
				}
				if(row["FirstExpectBuyDate"]!=null && row["FirstExpectBuyDate"].ToString()!="")
				{
					model.FirstExpectBuyDate=DateTime.Parse(row["FirstExpectBuyDate"].ToString());
				}
				if(row["ActualPay_Delivery"]!=null && row["ActualPay_Delivery"].ToString()!="")
				{
					model.ActualPay_Delivery=decimal.Parse(row["ActualPay_Delivery"].ToString());
				}
				if(row["ExpectPay_Delivery"]!=null && row["ExpectPay_Delivery"].ToString()!="")
				{
					model.ExpectPay_Delivery=decimal.Parse(row["ExpectPay_Delivery"].ToString());
				}
				if(row["HasPay_Delivery"]!=null && row["HasPay_Delivery"].ToString()!="")
				{
					if((row["HasPay_Delivery"].ToString()=="1")||(row["HasPay_Delivery"].ToString().ToLower()=="true"))
					{
						model.HasPay_Delivery=true;
					}
					else
					{
						model.HasPay_Delivery=false;
					}
				}
				if(row["HasPay"]!=null && row["HasPay"].ToString()!="")
				{
					if((row["HasPay"].ToString()=="1")||(row["HasPay"].ToString().ToLower()=="true"))
					{
						model.HasPay=true;
					}
					else
					{
						model.HasPay=false;
					}
				}
				if(row["IsBuyMoneyOK_Delivery"]!=null && row["IsBuyMoneyOK_Delivery"].ToString()!="")
				{
					if((row["IsBuyMoneyOK_Delivery"].ToString()=="1")||(row["IsBuyMoneyOK_Delivery"].ToString().ToLower()=="true"))
					{
						model.IsBuyMoneyOK_Delivery=true;
					}
					else
					{
						model.IsBuyMoneyOK_Delivery=false;
					}
				}
			}
			return model;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select id,Number,StoreID,State,Dateandtime,ExpectPriceSum,ActualPriceSum,ExpressPrice,StoreName,StoreNumber,DateandtimeSend,ActualBuyPriceSum,ExpectBuyPriceSum,IsBuyMoneyOK,ExpectPay,ActualPay,ExpressName,ExpressNumber,StoreProvince,StoreCity,StoreArea,StoreMobile,StoreTel,StoreContacts,StoreAddress,BuyDay,ExpectBuyDate,StoreAccount,StoreMasterAccount,StoreViceAccount,StoreFrozenAccount,ExpressID,ExpressTel,ExpressMobile,ExpressCode,ExpressDescription,BuyerID,SenderID,BuyerNumber,BuyerRealname,BuyerMobile,StoreUserID,BuyerUserID,FirstExpectBuyDate,ActualPay_Delivery,ExpectPay_Delivery,HasPay_Delivery,HasPay,IsBuyMoneyOK_Delivery ");
			strSql.Append(" FROM V_Orders ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ");
			if(Top>0)
			{
				strSql.Append(" top "+Top.ToString());
			}
			strSql.Append(" id,Number,StoreID,State,Dateandtime,ExpectPriceSum,ActualPriceSum,ExpressPrice,StoreName,StoreNumber,DateandtimeSend,ActualBuyPriceSum,ExpectBuyPriceSum,IsBuyMoneyOK,ExpectPay,ActualPay,ExpressName,ExpressNumber,StoreProvince,StoreCity,StoreArea,StoreMobile,StoreTel,StoreContacts,StoreAddress,BuyDay,ExpectBuyDate,StoreAccount,StoreMasterAccount,StoreViceAccount,StoreFrozenAccount,ExpressID,ExpressTel,ExpressMobile,ExpressCode,ExpressDescription,BuyerID,SenderID,BuyerNumber,BuyerRealname,BuyerMobile,StoreUserID,BuyerUserID,FirstExpectBuyDate,ActualPay_Delivery,ExpectPay_Delivery,HasPay_Delivery,HasPay,IsBuyMoneyOK_Delivery ");
			strSql.Append(" FROM V_Orders ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			strSql.Append(" order by " + filedOrder);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM V_Orders ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T.id desc");
			}
			strSql.Append(")AS Row, T.*  from V_Orders T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			SqlParameter[] parameters = {
					new SqlParameter("@tblName", SqlDbType.VarChar, 255),
					new SqlParameter("@fldName", SqlDbType.VarChar, 255),
					new SqlParameter("@PageSize", SqlDbType.Int),
					new SqlParameter("@PageIndex", SqlDbType.Int),
					new SqlParameter("@IsReCount", SqlDbType.Bit),
					new SqlParameter("@OrderType", SqlDbType.Bit),
					new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
					};
			parameters[0].Value = "V_Orders";
			parameters[1].Value = "id";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  BasicMethod
		#region  ExtensionMethod

		#endregion  ExtensionMethod
	}
}

